package com.example.Gethome.controller;

import com.example.Gethome.utils.SendMSNMessage;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class verifyController {

    private SendMSNMessage sendMSNMessage = new SendMSNMessage();

    private String test;

    @RequestMapping(path = "sendPhone")
    public void sendPhone(@RequestParam String phone) {
        String checkCode = sendMSNMessage.getCheckCode();
        sendMSNMessage.sendSMSMessage(phone, checkCode);
        test = checkCode;
    }

    @RequestMapping(path = "sendVerifyCode")
    public String sendVerifyCode(@RequestParam String phone, @RequestParam String verifyCode) {
        System.out.println(verifyCode + test);
        if (test.equals(verifyCode)) {
            // 说明验证码相符
            System.out.println("hh");
            return "success";
        } else {
            return "fail";
        }
    }


}
